package leetcode.每日一题;

import org.junit.Test;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;

/**
 * @author :songyaozhang
 * @date :Created 2021/7/23 18:57
 * @description :https://leetcode-cn.com/problems/check-if-all-the-integers-in-a-range-are-covered/
 */
public class 检查是否区域内所有整数都被覆盖s {
    @Test
    public void test() {
        Solution solution = new Solution();
        System.out.println(solution.isCovered(new int[][]{{1, 10}, {10, 20}}, 2, 5));
    }

    class Solution {
        public boolean isCovered(int[][] ranges, int left, int right) {
            for (int i = left; i <= right; i++) {
                boolean ok = false;
                for(int[] range : ranges) {
                    if (i >= range[0] && i <= range[1]) {
                        ok = true;
                        break;
                    }
                }
                if (!ok) return false;
            }
            return true;
        }
    }


}
